package com.yidu.t299.service.xp.impl;
import com.yidu.t299.dao.xp.ClassManageMapper;
import com.yidu.t299.domain.xp.Class;
import com.yidu.t299.domain.xp.ClassManage;
import com.yidu.t299.domain.xp.School;
import com.yidu.t299.domain.xp.StudentManage;
import com.yidu.t299.service.xp.ClassManageBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @descripion:
 * @auth: XuPan
 * @date: 2023/3/9 9:12
 * @version: 1.0
 */
@Service
@Transactional
public class ClassManageBizImpl implements ClassManageBiz {
    @Autowired
    private ClassManageMapper classManageMapper;//注入数据

    @Override
    public int deleteByPrimaryKey(Integer claId) {
        return classManageMapper.deleteByPrimaryKey(claId);
    }

    @Override
    public int insert(ClassManage record) {
        return classManageMapper.insert(record);
    }

    @Override
    public ClassManage selectByPrimaryKey(Integer claId) {
        return classManageMapper.selectByPrimaryKey(claId);
    }

    @Override
    public List<ClassManage> selectByPage(int rows, int page, String condition) {
        return classManageMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return classManageMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(ClassManage record) {
        return classManageMapper.updateByPrimaryKey(record);
    }

    @Override
    public String getCondition(ClassManage classManage) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        // 如果报班对象为空则直接返回条件字符串
        if (classManage == null){
            return condition;
        }
        if (classManage.getClassName() !=null){
            condition += " and c.class_name like '%" + classManage.getClassName()+"%'";
        }
        //返回条件字符串
        return condition;
    }

    @Override
    public List<Class> selectAllGetClass() {
        return classManageMapper.selectAllGetClass();
    }

    @Override
    public List<School> selectAllGetSchool() {
        return classManageMapper.selectAllGetSchool();
    }

    @Override
    public List<StudentManage> selectAllGetStudent() {
        return classManageMapper.selectAllGetStudent();
    }

    @Override
    public int selectByStudentName(String studentName) {
        return classManageMapper.selectByStudentName(studentName);
    }

    @Override
    public int selectByclassName(String className) {
        return classManageMapper.selectByclassName(className);
    }
}
